home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj0287.arc / SOUNDS.C < prev    next >
Text File  |  1986-12-15  |  984b  |  70 lines

  1. /* 
  2.  *    sounds -- make various sounds on demand 
  3.  */ 
  4. #include <stdio.h> 
  5. #include <conio.h> 
  6. #include <math.h> 
  7.  
  8. #define ESC    27 
  9.  
  10. extern void sound(unsigned int, float); 
  11.  
  12. main() 
  13.     int ch; 
  14.  
  15.     fprintf(stderr, "1=warble 2=error 3=confirm 4=warn\n"); 
  16.     fprintf(stderr, "Esc=quit\n"); 
  17.     while ((ch = getch()) != ESC) 
  18.         switch (ch) { 
  19.         case '1': 
  20.             warble(); 
  21.             break; 
  22.         case '2': 
  23.             error(); 
  24.             break; 
  25.         case '3': 
  26.             confirm(); 
  27.             break; 
  28.         case '4': 
  29.             warn(); 
  30.             break; 
  31.         } 
  32.     exit(0); 
  33. #define CYCLES    3 
  34. #define LOTONE    600 
  35. #define HITONE    1200 
  36. #define PERIOD    0.1 
  37.  
  38. warble() 
  39.     int i; 
  40.  
  41.     for (i = 0; i < 2 * CYCLES; ++i) 
  42.         if (i % 2) 
  43.             sound(LOTONE, PERIOD); 
  44.         else 
  45.             sound(HITONE, PERIOD); 
  46. error() 
  47.     float d = 0.1; 
  48.  
  49.     sound(440, d); 
  50.     sound(220, d); 
  51. confirm() 
  52.     float d = 0.1; 
  53.  
  54.     sound(440, d); 
  55.     sound(880, d); 
  56. warn() 
  57.     float d = 0.2; 
  58.  
  59.     sound(100, d); 
  60.